package com.wc.算法基础课.B第二讲数据结构.单调队列.矩形牛棚;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/3/23 22:31
 * @description https://www.acwing.com/problem/content/1415/
 */

public class Main {
    // 思路：遍历下边界，然后取当前位置的最大上边界作为高，找高两边满足要求的左右边界，就可以求出当前最大矩形的面积
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 3010;
    static int[][] g = new int[N][N];
    static int[][] h = new int[N][N];
    // 存左边第一个比自己小的数的位置
    static int[] l = new int[N];
    // 存右边第一个比自己小的数的位置
    static int[] r = new int[N];
    static int[] stk = new int[N];
    static int n, m, p, x, y, top;

    public static void main(String[] args) {
        n = sc.nextInt();
        m = sc.nextInt();
        p = sc.nextInt();
        while (p-- > 0) {
            x = sc.nextInt();
            y = sc.nextInt();
            g[x][y] = 1;
        }
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                if (g[i][j] == 0) h[i][j] = h[i - 1][j] + 1;
            }
        }
        int res = 0;
        for (int i = 1; i <= n; i++) {
            res = Math.max(res, work(h[i]));
        }
        out.println(res);
        out.flush();
    }

    static int work(int[] h) {
        // 哨兵,防止越界
        h[0] = h[m + 1] = -1;
        top = 0;
        stk[++top] = 0;
        for (int i = 1; i <= m; i++) {
            while (h[stk[top]] >= h[i]) top--;
            l[i] = stk[top];
            stk[++top] = i;
        }
        top = 0;
        stk[++top] = m + 1;
        for (int i = m; i >= 1; i--) {
            while (h[stk[top]] >= h[i]) top--;
            r[i] = stk[top];
            stk[++top] = i;
        }

        int res = 0;
        for (int i = 1; i <= m; i++) {
            res = Math.max(res, h[i] * (r[i] - l[i] - 1));
        }

        return res;
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}